﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XQ.RequestOfficeSupplies.BLL.Sys;
using XQ.RequestOfficeSupplies.DAL.DAL;
using XQ.RequestOfficeSupplies.DAL.Model;

namespace XQ.RequestOfficeSupplies.BLL.Charts
{
    public class ChartsBll
    {
        private readonly ChartsDal _chartsDal = new ChartsDal();

        /// <summary>
        ///     根据隐患总数（年）
        /// </summary>
        /// <param name="year">年份</param>

        /// <returns></returns>
        public List<ChartModel> GetCaseNumByDepAndMonth(int year)
        {
            var curYear = DateTime.Now.Year;
            var len = curYear == year ? DateTime.Now.Month : 12;
            var charts = new List<ChartModel>();
            for (var i = 0; i < len; i++)
            {
                var chartTotal = new ChartModel
                {
                    Total = _chartsDal.GetCaseNumByDepAndMonth(year, i + 1),
                    Month = i + 1,
                   // DepName = new DepartmentBll().GetDepartmentName()
                };
                charts.Add(chartTotal);
            }
            return charts;
        }
        /// <summary>
        ///     根据隐患总数（月）
        /// </summary>
        /// <param name="year">年份</param>
        /// <param name="month">月份</param>
        /// <param name="depId">部门</param>
        /// <returns></returns>
        public List<ChartModel> GetCaseNumByDepAndDay(int year, int month)
        {
            var dayCount = DateTime.DaysInMonth(year, month);
            var charts = new List<ChartModel>();
            for (var i = 0; i < dayCount; i++)
            {
                var chartTotal = new ChartModel
                {
                    Total = _chartsDal.GetCaseNumByDepAndDay(year, month, i + 1),
                    Month = i + 1,
                   // DepName = new DepartmentBll().GetDepartmentName()
                };
                charts.Add(chartTotal);
            }
            return charts;
        }

    }
}
